<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "orders".
 *
 * @property integer $o_id
 * @property integer $g_id
 * @property integer $c_id
 * @property string $o_num
 * @property string $o_total
 * @property string $add_data
 * @property string $o_status
 * @property string $beiyong
 * @property string $beiyong2
 *
 * @property Custom $c
 * @property Goods $g
 */
class Orders extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'orders';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['o_id', 'o_num', 'o_total', 'add_data', 'o_status'], 'required'],
            [['o_id', 'g_id', 'c_id'], 'integer'],
            [['o_num', 'o_total', 'o_status'], 'number'],
            [['add_data'], 'safe'],
            [['beiyong'], 'string', 'max' => 555],
            [['beiyong2'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'o_id' => '订单ID',
            'g_id' => '商品ID',
            'c_id' => '客户ID',
            'o_num' => '商品数量',
            'o_total' => 'O Total',
            'add_data' => 'Add Data',
            'o_status' => 'O Status',
            'beiyong' => 'Beiyong',
            'beiyong2' => 'Beiyong2',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getC()
    {
        return $this->hasOne(Custom::className(), ['c_id' => 'c_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getG()
    {
        return $this->hasOne(Goods::className(), ['g_id' => 'g_id']);
    }
}
